package com.example.servlet.idcollection;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.example.service.IdCollectionService;
import com.example.service.impl.IdCollectionServiceImpl;
import com.example.vo.IdCollectionVO;
import com.example.vo.ResponseData;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 获取个人的数字藏品
 */
@WebServlet("/MarketServlet/queryAll")
public class QueryAllServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/json;charset=utf-8");
        String username = req.getParameter("user");
        List<IdCollectionVO> list = new IdCollectionServiceImpl().getAll(username);
        resp.getWriter().println(JSON.toJSONString(ResponseData.ok(list)));
    }
}
